#region MIT Licence

//Copyright (c) 2007 Mono Overlay Routing Foundation Team
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.


#endregion


using System;
using System.Net;

using MonORF.Logging;
using MonORF.Messaging;
using MonORF.Networking;

namespace MonORF.Overlay {

    public class Chimera{//: IRouting {
      
      private static Chimera s_instance = null;
      private ChimeraHost m_me;
      private ChimeraHost m_bootstrap;
      private ChimeraState m_chimeraState;
      //private ChimeraGlobal m_chimeraGlobal;

//      public event EventHandler<DeliverEventArgs> OnDeliver;
//      public event EventHandler<ForwardEventArgs> OnForward;
//      public event EventHandler<RouteEventArgs> OnRoute;
      
      public Chimera(ChimeraState chimeraState)
      {
         if(s_instance == null){
            s_instance = this;
            m_chimeraState = chimeraState;
         }
      }

      public Chimera()
      {
         if(s_instance == null){
            s_instance = this;
         }
      }
      
      #region properties
      
      public ChimeraHost Me{
         get {return m_me;}
         set {m_me = value;}
      }

      public ChimeraHost Bootstrap{
         get {return m_bootstrap;}
         set {m_bootstrap = value;}
      }
      
      public ChimeraState ChimeraState{
         get{return m_chimeraState;}
         set{m_chimeraState = value;}
      }
      
      public static Chimera Instance{
         get{return s_instance;}
      }
      
      #endregion
      
      public ChimeraState Init(Int32 localPort)
      {
         //IPHostEntry iph;
         //String hostname;
         
         //inicialization
         m_chimeraState.LogService = new LogService();
         
         //inicialization
//         m_chimeraState.MessageService = new MessagingService(m_chimeraState);
         
         
         return m_chimeraState;
      }
      
      public void Join(ChimeraHost bootstrap)
      {
         throw new NotImplementedException();
      }
      
      public void Route<TMessage>(Key key, TMessage message, ChimeraHost hint)
      {
         throw new NotImplementedException();
      }
      
      public void Forward()
      {
         throw new NotImplementedException();
      }
      
      public void Deliver()
      {
         throw new NotImplementedException();
      }
      
      public void Update()
      {
         throw new NotImplementedException();
      }
      
      public void Send<TMessage>(Key key, TMessage message)
      {
         throw new NotImplementedException();
      }
      
      public void Ping(ChimeraHost host)
      {
         throw new NotImplementedException();
      }
   }
}
